<?php

/**
 * This is the model class for table "cs_insuredinfo".
 *
 * The followings are the available columns in table 'cs_insuredinfo':
 * @property integer $id
 * @property integer $importpolicy_id
 * @property string $InsuedName
 * @property string $InsuedZJNo
 * @property string $InsuedZJType
 * @property string $InsuedMobile
 * @property integer $create_time
 * @property string $birthday
 * @property string $sex
 * @property integer $approvaltrans_id
 */
class InsuredinfoF extends CActiveRecord
{
	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'cs_insuredinfo';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('InsuedName, InsuedZJNo, InsuedZJType, InsuedMobile, birthday, sex, approvaltrans_id', 'required'),
			array(' create_time, approvaltrans_id', 'numerical', 'integerOnly'=>true),
			array('InsuedName, InsuedZJNo, InsuedZJType, InsuedMobile, birthday', 'length', 'max'=>45),
			array('sex', 'length', 'max'=>3),
			array('insRelationApp', 'length', 'max'=>2),
			// The following rule is used by search().
			// @todo Please remove those attributes that should not be searched.
			array('id, InsuedName, InsuedZJNo, InsuedZJType, InsuedMobile, create_time, birthday, sex, approvaltrans_id, insRelationApp', 'safe', 'on'=>'search'),
		);
	}

	public function getDbConnection() {       
    	return Yii::app()->db;
    } 


	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'InsuedName' => 'Insued Name',
			'InsuedZJNo' => 'Insued Zjno',
			'InsuedZJType' => 'Insued Zjtype',
			'InsuedMobile' => 'Insued Mobile',
			'create_time' => 'Create Time',
			'birthday' => 'Birthday',
			'sex' => 'Sex',
			'approvaltrans_id' => 'Approvaltrans',
			'insRelationApp' => 'InsRelationApp',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 *
	 * Typical usecase:
	 * - Initialize the model fields with values from filter form.
	 * - Execute this method to get CActiveDataProvider instance which will filter
	 * models according to data in model fields.
	 * - Pass data provider to CGridView, CListView or any similar widget.
	 *
	 * @return CActiveDataProvider the data provider that can return the models
	 * based on the search/filter conditions.
	 */
	public function search()
	{
		// @todo Please modify the following code to remove attributes that should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('InsuedName',$this->InsuedName,true);
		$criteria->compare('InsuedZJNo',$this->InsuedZJNo,true);
		$criteria->compare('InsuedZJType',$this->InsuedZJType,true);
		$criteria->compare('InsuedMobile',$this->InsuedMobile,true);
		$criteria->compare('create_time',$this->create_time);
		$criteria->compare('birthday',$this->birthday,true);
		$criteria->compare('sex',$this->sex,true);
		$criteria->compare('approvaltrans_id',$this->approvaltrans_id);
		$criteria->compare('insRelationApp',$this->insRelationApp,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}

	/**
	 * Returns the static model of the specified AR class.
	 * Please note that you should have this exact method in all your CActiveRecord descendants!
	 * @param string $className active record class name.
	 * @return Insuredinfo the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
}
